package com.dengcj.epl.entity.ecology.hrm;

import cn.hutool.json.JSONUtil;
import com.dengcj.epl.enums.ecology.hrm.UserStatus;

/**
 * Ecology用户
 */
public class User {

    // 用户id
    private int id;

    // 姓名
    private String lastname;

    // 性别
    private int sex;

    // 电子邮箱
    private String email;

    // 手机号
    private String mobile;

    // 部门ID
    private int departmentId;

    // 部门名称
    private String departmentName;

    // 分部ID
    private int subcompanyId;

    // 分部名称
    private String subcompanyName;

    // 直接上级ID
    private int managerId;

    // 直接上级姓名
    private String managerName;

    // 岗位ID
    private int jobtitleId;

    // 岗位名称
    private String jobtitleName;

    // 登录名
    private String loginId;

    private int statusIndex;
    // 状态
    private UserStatus status;

    // 是否有效
    private boolean valid;

    // 安全级别
    private int seclevel;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getLastname() {
        return lastname;
    }

    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public int getDepartmentId() {
        return departmentId;
    }

    public void setDepartmentId(int departmentId) {
        this.departmentId = departmentId;
    }

    public String getDepartmentName() {
        return departmentName;
    }

    public void setDepartmentName(String departmentName) {
        this.departmentName = departmentName;
    }

    public int getSubcompanyId() {
        return subcompanyId;
    }

    public void setSubcompanyId(int subcompanyId) {
        this.subcompanyId = subcompanyId;
    }

    public String getSubcompanyName() {
        return subcompanyName;
    }

    public void setSubcompanyName(String subcompanyName) {
        this.subcompanyName = subcompanyName;
    }

    public int getManagerId() {
        return managerId;
    }

    public void setManagerId(int managerId) {
        this.managerId = managerId;
    }

    public String getManagerName() {
        return managerName;
    }

    public void setManagerName(String managerName) {
        this.managerName = managerName;
    }

    public int getJobtitleId() {
        return jobtitleId;
    }

    public void setJobtitleId(int jobtitleId) {
        this.jobtitleId = jobtitleId;
    }

    public String getJobtitleName() {
        return jobtitleName;
    }

    public void setJobtitleName(String jobtitleName) {
        this.jobtitleName = jobtitleName;
    }

    public String getLoginId() {
        return loginId;
    }

    public void setLoginId(String loginId) {
        this.loginId = loginId;
    }

    public UserStatus getStatus() {
        for (UserStatus userStatus : UserStatus.values()) {
            if(userStatus.getIndex() == this.statusIndex){
                return userStatus;
            }
        }

        return null;
    }

    public int getSeclevel() {
        return seclevel;
    }

    public void setSeclevel(int seclevel) {
        this.seclevel = seclevel;
    }

    public void setStatusIndex(int statusIndex) {
        this.statusIndex = statusIndex;
    }

    public boolean isValid() {
        return this.statusIndex < 4;
    }

    @Override
    public String toString(){
        return JSONUtil.parseObj(this).toStringPretty();
    }
}
